package com.example.lanouhn.bantangapp.activities.adapters;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.lanouhn.bantangapp.R;
import com.example.lanouhn.bantangapp.activities.contants.Search_deildelist;
import com.example.lanouhn.bantangapp.activities.contants.Search_product;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by lanouhn on 16/7/19.
 */
public class Adapter_FragmentSerach_deillist extends RecyclerView.Adapter<Adapter_FragmentSerach_deillist.MyViewHolder> {
    private Context context;
    List<Search_deildelist> list;


    public Adapter_FragmentSerach_deillist(Context context, List<Search_deildelist> list) {
        this.context = context;
        this.list = list;

    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.fragment_item_detaildelist_item,null);
        MyViewHolder viewHolder = new MyViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {

        holder.recyclerview_name.setText(list.get(position).getName());
        holder.recyclerview_en_name.setText(list.get(position).getEn_name());

        //图片
        Picasso.with(context).load(list.get(position).getIcon()).into(holder.recyclerview_iv);


    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder{

        private ImageView recyclerview_iv;
        private TextView  recyclerview_name;
        private TextView  recyclerview_en_name;
        public MyViewHolder(View itemView) {
            super(itemView);
            recyclerview_iv = (ImageView) itemView.findViewById(R.id.recyclerview_iv);
            recyclerview_name= (TextView) itemView.findViewById(R.id.recyclerview_name);
            recyclerview_en_name= (TextView) itemView.findViewById(R.id.recyclerview_en_name);


        }
    }
}
